package it.canraid.leaflet.model;

import it.canraid.leaflet.view.StatusMessageView;

import java.util.ArrayList;

import android.view.View;
import android.widget.ImageView;

public class ReadMessagePill {
    public ArrayList<WordPill> words = null;
    public ArrayList<LinePill> lines = null;
    public StatusPill status = null;
    public long timestampLastUpdate = System.currentTimeMillis();
    public ImageView messageImageThumb = null;// alla prima view in ListView!
    public StatusMessageView statusView = null;// alla prima view in ListView!
    public View itemView = null;// alla prima view in ListView!

    public ReadMessagePill(ArrayList<WordPill> words, ArrayList<LinePill> lines, StatusPill status) {
	this.words = words;
	this.lines = lines;
	this.status = status;
    }

    public ReadMessagePill(String ascii) {
	this.words = WordPill.extractWords(ascii);
	this.lines = LinePill.extractLines(ascii);
	this.status = StatusPill.extractStatus(ascii);
    }

    public String generateAscii() {
	StringBuffer ascii = new StringBuffer();

	for (int q = 0; q < words.size(); q++)
	    ascii.append(words.get(q).generateAscii());
	for (int w = 0; w < lines.size(); w++)
	    ascii.append(lines.get(w).generateAscii());
	ascii.append(status.generateAscii());
	return ascii.toString();
    }
}
